package cn.xiuxius.embedded.toolwindow;

public class OptionItem<T> {
    private final T value;
    private final String label;

    public OptionItem(T value, String label) {
        this.value = value;
        this.label = label;
    }

    public T getValue() {
        return value;
    }

    public String getDisplayValue() {
        return label;
    }

    public String getValueAsString() {
        return value != null ? value.toString() : "";
    }

    @Override
    public String toString() {
        return label;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (!(obj instanceof OptionItem)) return false;
        OptionItem<?> other = (OptionItem<?>) obj;
        return value == null ? other.value == null : value.equals(other.value);
    }

    @Override
    public int hashCode() {
        return value != null ? value.hashCode() : 0;
    }
}
